package com.hnhegui.backend.payment.controller;

import com.hnhegui.backend.entity.Result;
import com.hnhegui.backend.payment.api.PaymentRestApi;
import com.hnhegui.backend.payment.dto.request.PaymentRequestDTO;
import com.hnhegui.backend.payment.dto.response.PaymentResponseDTO;
import com.hnhegui.backend.payment.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 支付Controller
 */
@RestController
@Validated
@RequestMapping("/api/payments")
public class PaymentController implements PaymentRestApi {

    @Autowired
    private PaymentService paymentService;

    @Override
    public Result<PaymentResponseDTO> pay(@Validated PaymentRequestDTO request) {
        PaymentResponseDTO response = paymentService.initiatePayment(request);
        return Result.success(response);
    }
}
